/*
 * Copyright (c) 2008, Xiong Yingfei, the University of Tokyo
 * All rights reserved.
 */
package ac.jp.u_tokyo.SyncLib.language2;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

import ac.jp.u_tokyo.SyncLib.language.Const;
import ac.jp.u_tokyo.SyncLib.language.EvaluationFailedException;
import ac.jp.u_tokyo.SyncLib.language.GraphCombinatorBody;
import ac.jp.u_tokyo.SyncLib.language.SyncBody;

public class SGetExpr extends VarExpr
{
	
	private Const _key;
	private Var _dict;
	
	
	

	public void setKey(Const key)
	{
		_key = key;
	}


	public void setDict(Var dict)
	{
		_dict = dict;
	}


	public SGetExpr(int line)
	{
		super(line);
	}


	@Override
	public void addBody(Var var, boolean atLeft,
			GraphCombinatorBody body, Collection<String> genericParas)
			throws EvaluationFailedException
	{
		SyncBody result = NativeSyncFactory.createSGet(_key, !atLeft, getLine());
		List<Var> para = new LinkedList<Var>();
		para.add(_dict);
		para.add(var);
		body.addConnection(result, Helper.higherVar2LowerVar(para));
	}


	@Override
	public Collection<Var> getVarUsed(Collection<String> genericParas)
			throws EvaluationFailedException
	{
		Collection<Var> result = new LinkedList<Var>();
		result.add(_dict);
		return result;
	}

}
